#coding:utf-8
from locust import  HttpLocust,TaskSet,task
import  os
import  time
# 定义用户行为
from locust import HttpUser, TaskSet, task
# 定义用户行为类
class UserBehavior(TaskSet):
    @task  # 任务项
    def test_login(self):
        user_info = {
            'loginid': 'lzy',
            'pwd': 'newcapec',
            'captcha':'1111'
        }
        url = 'http://192.168.112.144:8080/aiface/login'
        res = self.client.post(url, data=user_info)
        if res.status_code == 302:
            print('登陆成功！')
        else:
            print('登陆失败！')

class WebSiteUser(HttpUser):
    task_create = UserBehavior
    max_wait = 5000
    min_wait = 1000
if __name__=='__main__':
    cmd = 'locust -f testlocust.py '
    os.system(cmd)